package cn.bdqn.controller.sys;

import cn.bdqn.entity.SysUser;
import cn.bdqn.service.sys.UserService;
import cn.bdqn.utils.MyLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.Enumeration;

/**
 * @ProjectName: ycbdqn
 * @Package: cn.bdqn.controller.sys
 * @Author: huat
 * @Date: 2020/3/5 13:01
 * @Version: 1.0
 */
@Controller
@RequestMapping("/sys/user")
public class UserController {

    @Autowired
    UserService userService;

    /**
     * 进入首页
     */
    @RequestMapping("index")
    public String index(){
        return "index";
    }

    /**
     * 修改密码
     * @param oldPassword 原密码
     * @param password 新密码
     * @return
     */
    @MyLog("修改密码")
    @RequestMapping("updatePassword")
    @ResponseBody
    public int updatePasswordByUserId(String oldPassword,String password,HttpSession session){
       return  userService.updatePasswordByUserId(oldPassword,password,((SysUser)session.getAttribute("user")).getId());

    }

}


